简书链接:原创shell添加网络适配器
文章字数:132,阅读全文大约需要1分钟

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18


Get-NetAdapter | Where-Object -Property DriverDescription -eq 'Microsoft KM-TEST Loopback Adapter'

Get-NetAdapter -Name 192.168.110.8 -ErrorAction SilentlyContinue

Rename-NetAdapter -Name $adapter.Name -NewName $Name -ErrorAction Stop
Write-Verbose -Message ("name is{0}" -f "FF")


New-LoopbackAdapter -Name IP_REDIRECT -Force

{4d36e972-e325-11ce-bfc1-08002be10318}



Rename-NetAdapter -Name $adapter.Name -NewName $Name -ErrorAction Stop

其原理就是执行devcon64.exe install C:\WINDOWS\inf\netloop.inf *MSLOOP就会自动产生一个适配器

循环插入

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Install-Module -Name LoopbackAdapter
Import-Module -Name LoopbackAdapter

$val = 0

while($val -lt 2) {
$val++ ;

# The name for the loopback adapter interface that will be created.
$loopback_name = "LoopbackAAA$val"

New-LoopbackAdapter -Name $loopback_name -Force

# Commented this line out but you're probably gonna want it so you don't end up like me
#Get-NetAdapter $loopback_name | Set-DNSClient –RegisterThisConnectionsAddress $False

Write-Host $val
}

New-LoopbackAdapter -Name test -Force